package com.woniuxy.controller;

import com.woniuxy.entity.Perm;
import com.woniuxy.entity.ResponseEntity;
import com.woniuxy.service.PermService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author：jojo
 * @Date：2022/3/8 14:45
 * @Description :TODO
 */
@RestController
@RequestMapping("/perm")
public class PermController {
    @Autowired(required = false)
    PermService permService;

    @ApiOperation(value = "权限添加方法（已弃用）")
    @RequestMapping("/add")
    public ResponseEntity addPerm(@RequestBody Perm perm){
        return permService.addPerm(perm);
    }

    @ApiOperation(value = "删除某个权限")
    @RequestMapping("/delet/{id}")
    public ResponseEntity delet(@PathVariable int id){
        return permService.deletPerm(id);
    }

    @ApiOperation(value = "更新某个权限")
    @RequestMapping("/update")
    public ResponseEntity update(@RequestBody Perm perm){
        return permService.update(perm);
    }

    @ApiOperation(value = "查询所有权限")
    @RequestMapping("/findAll")
    public ResponseEntity findAll(){
        return permService.findAll();
    }

    @ApiOperation(value = "查询该角色未拥有的权限")
    @RequestMapping("/findPerm/{roleid}")
    public ResponseEntity findPerm(@PathVariable("roleid") int roleid){
        return permService.findPerm(roleid);
    }

    @ApiOperation(value = "查询该角色已拥有的权限")
    @RequestMapping("/findPerm1/{roleid}")
    public ResponseEntity findPerm1(@PathVariable("roleid") int roleid){
        return permService.findPerm1(roleid);
    }
}
